package com.cloud.pharmaceuticalClient.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author zhozixiong
 * @date 2023/02/26
 */
@Getter
public enum UserOrderStatus {

    /**
     * 0 未支付
     * 1 未支付
     * 2 已发货
     * 3 已签收
     */
    UNPAID(0, "未支付"),
    PAID(1, "已支付"),
    SHIPPED(2, "已发货"),
    SIGN_FOR(3, "已签收");

    @EnumValue
    private Integer code;
    @JsonValue
    private String status;

    UserOrderStatus(Integer code, String status) {
        this.code = code;
        this.status = status;
    }

    @Override
    public String toString() {
        return status;
    }

    @JsonCreator
    public static UserOrderStatus getItem(Integer code) {
        for(UserOrderStatus status : values()) {
            if(status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }
}
